package com.kizuki.design.chain;

import lombok.extern.slf4j.Slf4j;


@Slf4j
public class PasswordVerify extends Verify{

    public static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";

    /**
     * 检验是否是复杂密码
     * @param userAccount
     */
    @Override
    protected VerifyResult handle(UserAccount userAccount) {
        String password = userAccount.getPassword();
        boolean isComplex = password.matches(PW_PATTERN);
        log.info("校验客户密码是否是复杂密码, password:{}, isComplex:{}", password, isComplex);
        return VerifyResult.buildResult(isComplex, "客户密码不是复杂密码");
    }
}
